#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <errno.h>
#include <string.h>
#include <signal.h>


#define LISTENQ 5
#define MAXLINE 100
#define SERV_PORT 5001

typedef struct sockaddr SA;
typedef struct sockaddr_in SA_IN;

void hello(const char* msg);

void exitWithError(const char * msg, int exitCode);

int Socket(int family, int type, int protocol);

void Connect(int sockfd, SA * serv_addr, int addrlen);

void Listen(int sockfd, int backlog);

void Bind(int sockfd, SA * serv_addr, int addrlen);

int Accept(int sockfd, SA * serv_addr, int* addrlen);

int Write(int sockfd, const char *ptr, size_t n);
// void Writen(int sockfd, char * buf, int n);
int Read(int sockfd, char * vptr, size_t n);

void Close(int sockfd);

int Fork();

void Inet_pton(int af, const char *src, void *dest);

char *Fgets(char *s, int size, FILE *stream);
int Fputs(char *s, FILE *stream);


void* Signal(int signo, void*(*func)(int));
void sig_chld(int signo);
void sig_pipe(int signo);